import React from 'react';
import ReactDOM from 'react-dom';
import { ConfigProvider } from 'antd';
import zh_CN from 'antd/lib/locale-provider/zh_CN';
import store from '@@/store';
import Router from '@@/route/router';
import { BrowserRouter } from 'react-router-dom';
import { StoreContext } from 'redux-react-hook';

import './index.less';

import reportWebVitals from './reportWebVitals';
import '@@/config/message';

if (!localStorage.getItem('sessionKey')) {
  window.history.replaceState(null, '', '/login');
}

ReactDOM.render(
  <React.StrictMode>
    <StoreContext.Provider value={store}>
      <ConfigProvider locale={zh_CN}>
        <BrowserRouter>
          <Router />
        </BrowserRouter>
      </ConfigProvider>
    </StoreContext.Provider>
  </React.StrictMode>,
  document.getElementById('root')
);

reportWebVitals();
